#include "Shader.h"
UINT compileFlags = 0;
HRESULT VertexShader::Initialize(
	ID3D11Device * device,
	const wstring & filePathName, 
	const string & entry,
	ID3DBlob ** ppErrMsg)
{
#if defined(DEBUG) || defined(_DEBUG)  
	compileFlags |= D3D10_SHADER_DEBUG | D3D10_SHADER_SKIP_OPTIMIZATION;
#endif
	ComPtr<ID3DBlob> tempCode;
	HRESULT hres;
	hres = D3DCompileFromFile(
		filePathName.c_str(), 0, 0,
		entry.c_str(), "vs_5_0", compileFlags, 0,
		tempCode.GetAddressOf(),
		ppErrMsg);
	if (FAILED(hres)) return hres;
	hres = device->CreateVertexShader(
		tempCode->GetBufferPointer(),
		tempCode->GetBufferSize(),
		NULL, vs.GetAddressOf());
	blob = tempCode;
	return hres;
}

ID3D11VertexShader * VertexShader::Get() const
{
	return vs.Get();
}

HRESULT PixelShader::Initialize(
	ID3D11Device * device, 
	const wstring & filePathName, 
	const string & entry,
	ID3DBlob ** ppErrMsg)
{
#if defined(DEBUG) || defined(_DEBUG)  
	compileFlags |= D3D10_SHADER_DEBUG | D3D10_SHADER_SKIP_OPTIMIZATION;
#endif
	ComPtr<ID3DBlob> tempCode;
	HRESULT hres;
	hres = D3DCompileFromFile(
		filePathName.c_str(), 0, 0,
		entry.c_str(), "ps_5_0", compileFlags, 0,
		tempCode.GetAddressOf(),
		ppErrMsg);
	hres = device->CreatePixelShader(
		tempCode->GetBufferPointer(),
		tempCode->GetBufferSize(),
		NULL, ps.GetAddressOf());
	blob = tempCode;
	return hres;
}

ID3D11PixelShader * PixelShader::Get() const
{
	return ps.Get();
}
